<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    window.onload = function () {
        var bet = document.getElementById("bet");
        var num = 0;
        //setInterval定时调用
        var sil = setInterval(function () {
            bet.innerHTML = num++;
            //关闭定时器
            if(num==10){
                clearInterval(sil);
            }
        },1000);
    };
</script>
<body>
    <h1 id="bet"></h1>
</body>
</html>